<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>代码生成</title>
    <link rel="shortcut icon" href="#"/>
    <link rel="stylesheet" type="text/css" href="../css/common/element-ui.css">
    <link rel="stylesheet" type="text/css" href="../css/genCode.css">
    <script src="../js/base-utils.js"></script>
    <script src="../js/common/vue2.js"></script>
    <script src="../js/common/element-ui.js"></script>
    <script src="../js/common/axios.min.js"></script>
    <script src="../js/common/vue-resource.min.js"></script>
</head>

<body>
<div id="app" v-loading="downloadLoading" element-loading-text="正在生成代码，请稍等...">

    <el-container style="height: 100%">
        <el-aside class="el-aside-border center" width="25%">
            <!-- 数据库配置搜索区域 -->
            <div align="left">
                <el-divider><i class="el-icon-setting"></i><b>数据源配置</b></el-divider>

                <el-button size="small" style="background-color: #67C23A" type="primary" icon="el-icon-folder-add" @click="addDataSource">+数据源</el-button>
                <el-button size="small" type="primary" size="medium" icon="el-icon-search" @click="searchDataSource(true)"></el-button>
                <el-input size="small" v-model="dbName" placeholder="请输入数据源名称搜索..." style="width: 45%;" @keyup.enter.native="searchDataSource(true)"></el-input>
            </div>

            <!-- -------------------------------------------------url示例---------------------------------------------------- -->
            <el-dialog :visible.sync="exampleData.exampleDataVisible" title="url示例" width="50%" style="height: 100%;" align="center">
                <el-descriptions class="margin-top" :column="1" border>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> MYSQL
                        </template>
                        <el-input type="text" v-model="exampleData.mysql"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> ORACLE
                        </template>
                        <el-input type="text" v-model="exampleData.oracle"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> DB2
                        </template>
                        <el-input type="text" v-model="exampleData.db2"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> KING
                        </template>
                        <el-input type="text" v-model="exampleData.king"></el-input>
                    </el-descriptions-item>
                </el-descriptions>
            </el-dialog>

            <!-- -------------------------------------------------增加数据源配置---------------------------------------------------- -->
            <el-dialog :visible.sync="dataSourceVisible" title="数据源配置" width="80%" style="height: 100%;"
                       v-loading="saveDataSourceLoading" element-loading-text="加载中..." align="center">
                <el-descriptions class="margin-top" :column="1" border>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> 名称
                        </template>
                        <el-input v-model="saveDataSource.dbName" placeholder="请输入配置名称..." maxlength="20"
                                  show-word-limit></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> 类型
                        </template>
                        <div align="left">
                            <el-radio v-model="saveDataSource.dataType" label="mysql" border>MYSQL</el-radio>
                            <el-radio v-model="saveDataSource.dataType" label="oracle" border>ORACLE</el-radio>
                            <el-radio v-model="saveDataSource.dataType" label="db2" border>DB2</el-radio>
                            <el-radio v-model="saveDataSource.dataType" label="kingbase8" border>KING_BASE8</el-radio>
                        </div>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> 地址
                            <el-button type="text" @click="exampleUrl">( 示例 )</el-button>
                        </template>
                        <el-input type="text" v-model="saveDataSource.url" placeholder="详情请查看左边的示例..."></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> 库名/表空间
                        </template>
                        <el-input v-model="saveDataSource.libraryName" placeholder="请输入库名/表空间"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> 账号
                        </template>
                        <el-input v-model="saveDataSource.username" placeholder="请输入账号..."></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-open"></i> 密码
                        </template>
                        <el-input v-model="saveDataSource.password" show-password
                                  placeholder="请输入密码..."></el-input>
                    </el-descriptions-item>
                </el-descriptions>
                <el-button type="primary" icon="el-icon-upload" @click="saveDataSourceMet">保存</el-button>
                <el-button type="primary" @click="dataSourceVisible = false">取消</el-button>
                <el-button type="primary" @click="emptyDataSource">清空</el-button>
            </el-dialog>
            <!-- -------------------------------------------------数据库配置列表---------------------------------------------------- -->
            <div style="height: 550px;">
                <el-table height="550" v-loading="dataSourceLoading" @selection-change="" :data="dataSource"
                          element-loading-text="加载中..." border stripe fit ref="tb" @row-click="rowClick"
                          :header-cell-style="{background:'#c6e2ff',color:'#606266'}" @row-dblclick="editDataSource"
                          @row-contextmenu="rightClick">

                    <el-table-column type="selection" width="55" align="center"></el-table-column>

                    <el-table-column label="配置名称" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.dbName }}
                        </template>
                    </el-table-column>
                    <el-table-column label="类型" align="center" width="100">
                        <template slot-scope="scope">
                            {{ scope.row.dataType }}
                        </template>
                    </el-table-column>
                </el-table>
            </div>

            <!-- 数据库配置分页 -->
            <div class="pagination" align="center">
                <el-pagination background :current-page="page.currentPage" :page-size="page.pageSize"
                               layout="total, prev, pager, next" :total="page.totalCount" @size-change="sourcePageSize"
                               @current-change="sourceCurrentPage">
                </el-pagination>
            </div>

            <div id="contextmenu" v-show="menuVisible" class="menu">
                <div class="contextmenu__item" @click="editDataSourceRig(CurrentRow)">修改</div>
                <div class="contextmenu__item" @click="connectDataSource(CurrentRow)">连接</div>
                <div class="contextmenu__item" @click="deleteDataSource(CurrentRow)">删除</div>
            </div>
        </el-aside>




        <el-main class="el-aside-border center" style="margin-left: 5px">
            <!-- ------------------------------------------------表集----------------------------------------------------- -->
            <el-divider><i class="el-icon-setting"></i><b>策略配置</b></el-divider>

            <div align="left">
                <el-button size="small" style="background-color: #67C23A" type="primary" icon="el-icon-download" @click="downloadFile">生成代码</el-button>
                <el-button size="small" type="primary" icon="el-icon-setting" @click="strategyVisible = true">策略配置</el-button>
                <el-button size="small" type="primary" icon="el-icon-search" @click="searchTableList(true)"></el-button>


                <el-input size="small" v-model="tableName" placeholder="请输入表名称搜索..." style="width: 300px;" @keyup.enter.native="searchTableList(true)"></el-input>
            </div>


            <!-- 表集 -->
            <div style="height: 550px">
                <el-table height="550" v-loading="tableLoading" @selection-change="tableSelection"
                          :data="tableList" element-loading-text="加载中..." border stripe fit ref="table"
                          @row-click="tableRowClick" :header-cell-style="{background:'#c6e2ff',color:'#606266'}">
                    <el-table-column type="selection" width="55" align="center"></el-table-column>

                    <el-table-column label="表名称" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.tableName }}
                        </template>
                    </el-table-column>

                    <el-table-column label="表注释" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.tableComment }}
                        </template>
                    </el-table-column>
                </el-table>
            </div>

            <!-- 表集分页 -->
            <div class="pagination" align="center">
                <el-pagination background :current-page="tablePage.currentPage" :page-sizes="[10, 50, 100, 200]"
                               :page-size="tablePage.pageSize" layout="total, sizes, prev, pager, next, jumper"
                               :total="tablePage.totalCount" @size-change="tablePageSize"
                               @current-change="tableCurrentPage">
                </el-pagination>
            </div>

            <!-- --------------------------------------------------策略配置--------------------------------------------------- -->
            <el-dialog :visible.sync="strategyVisible" title="策略配置" width="95%">
                <div>

                    <el-descriptions class="margin-top" :column="3" border>
                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-open"></i> 选择配置
                            </template>
                            <el-select size="medium" v-model="strategyName" value-key="id" filterable @change="optionStrategy">
                                <el-option v-for="item in strategyList" :key="item.id" :value="item" :label="item.name"></el-option>
                            </el-select>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-user"></i> 创建人
                            </template>
                            <el-input v-model="strategy.author" placeholder="默认值:Author"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-eleme"></i> 忽略表名前缀
                            </template>
                            <el-input v-model="strategy.ignoreTablePrefixs"
                                      placeholder="忽略表名前缀，多个请使用英文的逗号分隔"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-open"></i> Swagger
                            </template>
                            <el-switch v-model="strategy.enableSwagger" active-color="#13ce66"
                                       inactive-color="#ff4949" :active-value="true" :inactive-value="false">
                            </el-switch>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-open"></i> Lombok
                            </template>
                            <el-switch v-model="strategy.enableLombok" active-color="#13ce66"
                                       inactive-color="#ff4949" :active-value="true" :inactive-value="false">
                            </el-switch>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-open"></i> Boolean忽略is
                            </template>
                            <el-switch v-model="strategy.ignoreBooleanPrefix" active-color="#13ce66"
                                       inactive-color="#ff4949" :active-value="true" :inactive-value="false">
                            </el-switch>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-guide"></i> parents包名
                            </template>
                            <el-input v-model="strategy.parentPath" placeholder="默认值:com"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-guide"></i> Entity包名
                            </template>
                            <el-input v-model="strategy.entityPack" placeholder="默认值:entity"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-guide"></i> Mapper包名
                            </template>
                            <el-input v-model="strategy.mapperPack" placeholder="默认值:mapper"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-guide"></i> Service包名
                            </template>
                            <el-input v-model="strategy.servicePack" placeholder="默认值:service"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-guide"></i> ServiceImpl包名
                            </template>
                            <el-input v-model="strategy.serviceImplPack" placeholder="默认值:service.impl"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-copy-document"></i> ServiceImpl父类
                            </template>
                            <el-input v-model="strategy.superServiceImplClass"
                                      placeholder="如：com.chen.service.BaseService"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-discount"></i> 乐观锁
                            </template>
                            <el-input v-model="strategy.versionColumnName" placeholder="默认值:revision"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-discount"></i> 逻辑删除
                            </template>
                            <el-input v-model="strategy.logicDeleteColumnName"
                                      placeholder="默认值:del_flag"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <i class="el-icon-copy-document"></i> Mapper父类
                            </template>
                            <el-input v-model="strategy.superMapperClass"
                                      placeholder="如：com.chen.common.mybatis.scope.ProBaseMapper"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <el-button type="success" @click="saveStrategyMet" circle>保存</el-button>
                                <el-button type="danger" @click="deleteStrategy" circle>删除</el-button>
                            </template>
                            <el-input v-model="strategyName" placeholder="请输入策略配置名称..." maxlength="20"
                                      show-word-limit @keyup.enter.native="saveStrategyMet"></el-input>
                        </el-descriptions-item>

                        <el-descriptions-item v-loading="saveFillLoading" element-loading-text="正在保存..." >
                            <template slot="label">
                                <i class="el-icon-s-finance"></i> 自动填充
                            </template>
                            <el-input placeholder="请输入列名" v-model="saveFill.columnName"
                                      class="input-with-select" @keyup.enter.native="saveFillMet">
                                <el-select v-model="saveFill.fieldFillType" slot="prepend"
                                           placeholder="请选择填充类型">
                                    <el-option label="DEFAULT" value="DEFAULT"></el-option>
                                    <el-option label="INSERT" value="INSERT"></el-option>
                                    <el-option label="UPDATE" value="UPDATE"></el-option>
                                    <el-option label="INSERT_UPDATE" value="INSERT_UPDATE"></el-option>
                                </el-select>
                                <el-button slot="append" icon="el-icon-edit" @click="saveFillMet"
                                           style="background: #409EFF;color: #fff;">添加</el-button>
                            </el-input>
                        </el-descriptions-item>
                    </el-descriptions>

                    <br>
                    <!-- 自动填充配置 -->
                    <div style="height: 330px;">
                        <el-table height="330" v-loading="fillLoading" @selection-change="fillSelection"
                                  :data="fillList" element-loading-text="加载中..." border stripe fit ref="fill"
                                  @row-click="fillRowClick"
                                  :header-cell-style="{background:'#c6e2ff',color:'#606266'}">
                            <el-table-column type="selection" width="55" align="center"></el-table-column>

                            <el-table-column label="列名" align="center">
                                <template slot-scope="scope">
                                    {{ scope.row.columnName }}
                                </template>
                            </el-table-column>

                            <el-table-column label="填充类型" align="center">
                                <template slot-scope="scope">
                                    {{ scope.row.fieldFillType }}
                                </template>
                            </el-table-column>

                            <el-table-column label="操作" align="center" width="87"
                                             class-name="small-padding fixed-width">
                                <template slot-scope="scope">
                                    <el-tooltip class="item" effect="dark" content="删除" placement="right">
                                        <el-button size="mini" type="danger" icon="el-icon-delete"
                                                   @click="deleteFill(scope.row.id)"></el-button>
                                    </el-tooltip>

                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>

            </el-dialog>

        </el-main>
    </el-container>

</div>
</body>
<script src="../js/genCode.js"></script>
</html>